package com.cy4;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class ArrayListToFileUp {
    public static void main (String[] args) throws IOException {
        ArrayList<Student> array = new ArrayList<Student>();
        array.add(new Student("202010111402","陈勇","21","平昌"));
        array.add(new Student("202010111401","曹海","21","四川"));
        array.add(new Student("202010111420","杨明川","20","四川"));
        array.add(new Student("1314520250","袁湘","21","平昌"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("myCharStream\\array.txt"));
        for (Student student : array) {
            Student s = student;
            StringBuilder sb = new StringBuilder();
            sb.append(s.getId()).append(",").append(s.getName()).append(",").append(s.getAge()).append(",").append(s.getAddress());
            bw.write(sb.toString());
            bw.newLine();
            bw.flush();
        }
        bw.close();
    }
}
